<%@page import="com.nisco.dms.entity.Role"%>
<%@page import="com.nisco.dms.entity.Menu"%>
<%@page import="com.nisco.dms.entity.RolePermission"%>
<%@page import="java.util.*"%>
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"
	trimDirectiveWhitespaces="true"%>
<%@ include file="/WEB-INF/views/include.inc.jsp"%>
<%
	String basePath1 = request.getContextPath();
%>
<%!
public String tree1(Menu module,String roleId,String basePath) {
	if (module.getChildren().isEmpty()) {
		return "";
	}
	StringBuffer buffer = new StringBuffer();
	buffer.append("<ul>" + "\n");
	for(Menu o : module.getChildren()) {
		if(o.getProgram() == null){
			buffer.append("<li><a href=\"" + basePath + "/role/list/" + o.getId() +"/"+roleId+ "\" target=\"ajax\" rel=\"jbsxBox2module\">" + o.getStrName() + "</a>" + "\n");
		}else{
		buffer.append("<li><a href=\"" + basePath + "/role/list/" + o.getProgram().getId() +"/"+roleId+ "\" target=\"ajax\" rel=\"jbsxBox2module\">" + o.getStrName() + "</a>" + "\n");
		}buffer.append(tree1(o,roleId, basePath));
		buffer.append("</li>" + "\n");
	}
	buffer.append("</ul>" + "\n");
	return buffer.toString();
}
%>
<head>
<script type="text/javascript">
	$(function() {
		$(":checkbox").click(function() {
			event.cancelBubble = true;
		});
	});
</script>
</head>
<h2 class="contentTitle">修改角色</h2>
<form method="post" action="${ctx}/role/alterPremission" class="required-validate pageForm" onsubmit="return validateCallback(this, dialogAjaxDone);">
	<input type="hidden" name="id" value="${role.id }">
	<div class="pageFormContent" layoutH="97">
		<dl>
			<dt>名称：</dt>
			<dd>
				<input type="text" name="strName" class="required" size="32"
					maxlength="32" alt="请输入角色名称" value="${role.strName }" readonly="readonly"/>
			</dd>
		</dl>

		<div style="float: left; display: block; overflow: auto; width: 240px; border: solid 1px #CCC; line-height: 20px;height: 300px">
			<ul class="tree [treeFolder  [collapse]]" oncheck="kkk"
				id="defindetree">
				<li><a>${module.strName }</a> 
<%
 	Role role = (Role) request.getAttribute("role");
    String id = role.getId();
    Menu module = (Menu) request.getAttribute("module");
 %> 
 <%=tree1(module,id,basePath1)%>
				</li>
			</ul>
		</div>
		<div id="jbsxBox2module" class="unitBox" style="float:left;display: block; overflow: auto; width: 200px; border: solid 1px #CCC;margin-left: 10px;line-height: 20px;height: 300px">
					<!--#include virtual="list1.html" -->
		</div>
	</div>

	<div class="formBar">
		<ul>
			<li><div class="buttonActive">
					<div class="buttonContent">
						<button type="submit">确定</button>
					</div>
				</div></li>
			<li><div class="button">
					<div class="buttonContent">
						<button type="button" class="close">关闭</button>
					</div>
				</div></li>
		</ul>
	</div>
</form>